import React from "react";
import {Tag} from "antd";
import {getString} from "@/util/local-storage.ts";
import {LOGIN_EXPIRE_TIME_KEY} from "@/global/constant.ts";

/**
 * 检查当前登录是否过期
 */
export const loginIsExpired = (): React.ReactNode => {
    const loginExpiredTime = getString(LOGIN_EXPIRE_TIME_KEY);
    const isExpired = loginExpiredTime && new Date(loginExpiredTime) > new Date();
    if (isExpired){
        return <Tag color={"#2f7a0a"}>用户正常</Tag>
    }
    return <Tag color={"#5c1212"}>用户过期</Tag>
}